package com.example.tijian_doctor_backend.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.tijian_doctor_backend.dto.OrdersPageResponseDTO;
import com.example.tijian_doctor_backend.dto.OrdersResponseDTO;
import com.example.tijian_doctor_backend.dto.SelectForm;
import com.example.tijian_doctor_backend.mapper.HospitalMapper;
import com.example.tijian_doctor_backend.mapper.OrdersMapper;
import com.example.tijian_doctor_backend.mapper.SetmealMapper;
import com.example.tijian_doctor_backend.mapper.UsersMapper;
import com.example.tijian_doctor_backend.pojo.Hospital;
import com.example.tijian_doctor_backend.pojo.Orders;
import com.example.tijian_doctor_backend.pojo.Setmeal;
import com.example.tijian_doctor_backend.pojo.Users;
import com.example.tijian_doctor_backend.service.OrdersService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


/**
 * @author: bong~
 * @description: TODO
 * @date: 2024/6/17 13:37
 * @version: 1.0
 */
@Service
public class OrdersServiceImpl extends ServiceImpl<OrdersMapper, Orders> implements OrdersService {

    @Autowired
    private OrdersMapper ordersMapper;
    @Autowired
    private UsersMapper usersMapper;

    @Autowired
    private HospitalMapper hospitalMapper;
    @Autowired
    private SetmealMapper setmealMapper;



    @Override
    public OrdersPageResponseDTO selectOrderByForm(SelectForm selectForm) {



        Integer page=selectForm.getPageNum()==null?1:selectForm.getPageNum();
        Integer pageSize=selectForm.getMaxPageNum()==null?10:selectForm.getMaxPageNum();

        PageHelper.startPage(page,pageSize);

        Page<OrdersResponseDTO> pages=ordersMapper.selectOrderByForm(selectForm);

        List<OrdersResponseDTO> list=pages.getResult();

        long total=pages.getTotal();
        Integer curPageSize=pages.getPageSize();

        return new OrdersPageResponseDTO(list,total,curPageSize);

    }
}
